﻿using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPRedisHelper
{
    public class CPRedisHelper
    {
        public static string _conn = ConfigurationManager.AppSettings["RedisHost"]?? "127.0.0.1:6379";

      
        #region string类型


        /// <summary>
        /// 取值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string StringGet(string key)
        {
            try
            {
                using (var client = ConnectionMultiplexer.Connect(_conn))
                {
                    return client.GetDatabase().StringGet(key);
                }
            }
            catch (Exception)
            {
                return null;
            }
        }


        public static bool StringSet(string key, string value)
        {
            using (var client = ConnectionMultiplexer.Connect(_conn))
            {
                return client.GetDatabase().StringSet(key,value);
            }
        }

        #endregion
        #region 泛型

        #endregion
    }
}
